import Vue from 'vue'
import Router from 'vue-router'
import store from '../store'
Vue.use(Router)

import Layout from '@/layout'

/* Router Modules*/
// import chartsRouter from './modules/charts'
// import warehouseRouter from './modules/warehouse'
// import nestedRouter from './modules/nested'
console.log('store', store.state.user)
// const user = store.state.user.user
export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    redirect: 'homepage',
    component: () => import('../views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/login/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error-page/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error-page/401'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: 'homepage',
    children: [
      {
        path: 'homepage',
        component: () => import('@/views/index'),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/new-item',
    component: Layout,
    name: 'new-item',
    meta: { title: '新品创建', icon: 'form', roles: ['R017001', 'R017002', 'AR000589'], affix: true },
    children: [
      {
        path: 'fristAudit',
        name: 'fristAudit',
        component: () => import('@/views/new-item/frist-audit/list'),
        meta: { title: '供应商信息初审', icon: 'table', affix: true }
      },
      {
        path: 'buyerCreate',
        name: 'buyerCreate',
        component: () => import('@/views/new-item/create/list'),
        meta: { title: '自有商品新增', icon: 'table', affix: true }
      },
      {
        path: 'validate',
        name: 'validate',
        component: () => import('@/views/new-item/validate/list'),
        meta: { title: '数据校验', icon: 'table', affix: true }
      },
      {
        path: 'bpms',
        name: 'bpms',
        component: () => import('@/views/new-item/bpms/list'),
        meta: { title: '提交审核', icon: 'table', affix: true }
      },
      {
        path: 'created',
        name: 'created',
        component: () => import('@/views/new-item/created/list'),
        meta: { title: '出号商品查询', icon: 'table', affix: true }
      },
      {
        path: 'lead-time',
        name: 'lead-time',
        component: () => import('@/views/report/new-item/lead-time'),
        meta: { title: 'lead time统计', icon: 'table', affix: true }
      }
    ]
  },
  {
    path: '/change-item',
    component: Layout,
    redirect: 'index',
    name: 'change-item',
    meta: { title: '商品维护', icon: 'form', roles: ['R017001', 'R017002', 'AR000589'], affix: true },
    children: [
      {
        path: '1',
        name: 1,
        component: () => import('@/views/change-item/list'),
        meta: { title: '商品信息变更', icon: 'table', affix: true }
      },
      {
        path: '2',
        name: 2,
        component: () => import('@/views/change-item/list'),
        meta: { title: '交叉商品维护', icon: 'table', affix: true }
      },
      {
        path: '3',
        name: 3,
        component: () => import('@/views/change-item/list'),
        meta: { title: 'Trait号变更', icon: 'table', affix: true }
      },
      {
        path: '4',
        name: 4,
        component: () => import('@/views/change-item/list'),
        meta: { title: 'PLU#变更', icon: 'table', affix: true }
      },
      {
        path: '6',
        name: 6,
        component: () => import('@/views/change-item/list'),
        meta: { title: '商品删除', icon: 'table', affix: true }
      }
    ]
  },
  {
    path: '/active-item',
    name: 'active-item',
    component: Layout,
    redirect: 'index',
    meta: { title: '激活转类型', icon: 'form', roles: ['R017001', 'R017002', 'AR000589'], affix: true },
    children: [
      {
        path: '/item-status',
        name: 'item-status',
        component: () => import('@/views/active-item/index'),
        meta: { title: '商品激活', icon: 'table', affix: true },
        children: [
          {
            path: '/item-status/create',
            name: 'item-status-create',
            component: () => import('@/views/active-item/create/status-list'),
            meta: { title: '采购新增激活', icon: 'form', affix: true }
          },
          {
            path: '/item-status/first-audit',
            name: 'item-status-first-audit',
            component: () => import('@/views/active-item/first-audit/status-list'),
            meta: { title: '供应商信息初审', icon: 'form', affix: true }
          },
          {
            path: '/item-status/validate',
            name: 'item-status-validate',
            component: () => import('@/views/active-item/validate/status-list'),
            meta: { title: '数据校验', icon: 'form', affix: true }
          },
          {
            path: '/item-status/bpms',
            name: 'item-status-bpms',
            component: () => import('@/views/active-item/bpms/status-list'),
            meta: { title: '提交审核', icon: 'form', affix: true }
          }
        ]
      },
      {
        path: '/item-type',
        name: 'item-type',
        component: () => import('@/views/active-item/index'),
        meta: { title: '商品转类型', icon: 'table', affix: true },
        children: [
          {
            path: '/item-type/create',
            name: 'item-type-create',
            component: () => import('@/views/active-item/create/type-list'),
            meta: { title: '采购新增转类型', icon: 'form', affix: true }
          },
          {
            path: '/item-type/validate',
            name: 'item-type-validate',
            component: () => import('@/views/active-item/validate/type-list'),
            meta: { title: '数据校验', icon: 'form', affix: true }
          },
          {
            path: '/item-type/bpms',
            name: 'item-type-bpms',
            component: () => import('@/views/active-item/bpms/type-list'),
            meta: { title: '提交审核', icon: 'form', affix: true }
          }
        ]
      }
    ]
  },
  {
    path: '/rules',
    component: Layout,
    redirect: 'list',
    name: 'rules',
    meta: { title: '规则管理', icon: 'form', roles: ['R017001', 'AR000589'], affix: true },
    children: [
      {
        path: '/rules/rule/index',
        name: 'ruleIndex',
        component: () => import('@/views/rules/rule/index'),
        meta: { title: '规则列表', icon: 'table', affix: true }
      },
      {
        path: '/rules/rule1/list',
        name: 'rule1',
        component: () => import('@/views/rules/rule1/list'),
        meta: { title: '规则1', icon: 'table', affix: true }
      },
      {
        path: '/rules/rule2/list',
        name: 'rule2',
        component: () => import('@/views/rules/rule2/list'),
        meta: { title: '规则2', icon: 'table', affix: true }
      },
      {
        path: '/rules/rule3/list',
        name: 'rule3',
        component: () => import('@/views/rules/rule3/list'),
        meta: { title: '规则3', icon: 'table', affix: true }
      },
      {
        path: '/rules/rule-maintenance/list',
        name: 'rule-def',
        component: () => import('@/views/rules/rule-maintenance/list'),
        meta: { title: '规则维护', icon: 'table', affix: true },
        hidden: true
      }
    ]
  },
  {
    path: '/mda',
    component: Layout,
    redirect: 'list',
    name: 'mda',
    meta: { title: 'MDA审核', icon: 'form', roles: ['R017001', 'R017004'], affix: true },
    children: [
      {
        path: '/mda/newItemList',
        name: 'newItem',
        component: () => import('@/views/mda/newItemList'),
        meta: { title: '新品创建', icon: 'table', affix: true }
      },
      {
        path: '/mda/fieldChangeList',
        name: 'fieldChangeList',
        component: () => import('@/views/mda/fieldChangeList'),
        meta: { title: '商品信息维护', icon: 'table', affix: true }
      },
      {
        path: '/mda/activeList',
        name: 'activeList',
        component: () => import('@/views/mda/activeList'),
        meta: { title: '商品激活', icon: 'table', affix: true }
      },
      {
        path: '/mda/traitList',
        name: 'traitList',
        component: () => import('@/views/mda/traitList'),
        meta: { title: 'trait变更', icon: 'table', affix: true }
      },
      {
        path: 'lead-time',
        name: 'lead-time',
        component: () => import('@/views/report/new-item/lead-time'),
        meta: { title: 'lead time统计', icon: 'table', affix: true }
      }
    ]
  },
  {
    path: '/item-file',
    component: Layout,
    redirect: 'list',
    name: 'item-file',
    meta: { title: 'Item File', icon: 'form', roles: ['R017001', 'R017003'], affix: true },
    children: [
      {
        path: '/item-file/list',
        name: 'itemFile',
        component: () => import('@/views/item-file/tabIndex'),
        meta: { title: 'Item File', icon: 'table', affix: true }
      }
    ]
  },
  {
    path: '/system-manage',
    component: Layout,
    redirect: 'list',
    name: 'system-manage',
    meta: { title: '系统管理', icon: 'form', roles: ['R017001', 'R017013', 'AR000589'], affix: true },
    children: [
      {
        path: '/system-manage/plugs/list',
        name: 'plugs',
        component: () => import('@/views/system-manage/plugs/list'),
        meta: { title: '外挂清单维护', icon: 'table', affix: true, roles: ['R017001', 'R017013', 'AR000589'] }
      },
      {
        path: '/system-manage/template-manage',
        name: 'template-manage',
        component: () => import('@/views/system-manage/template-manage/list'),
        meta: { title: '导出模板维护', icon: 'table', affix: true, roles: ['R017001', 'AR000589'] }
      },
      {
        path: '/system-manage/host',
        name: 'host-manage',
        component: () => import('@/views/system-manage/host/apiList'),
        meta: { title: 'HOST API维护', icon: 'table', affix: true, roles: ['R017001', 'AR000589'] }
      },
      {
        path: '/system-manage/suspend',
        name: 'suspend-manage',
        component: () => import('@/views/system-manage/suspend/list'),
        meta: { title: '出号暂停计划', icon: 'table', affix: true, roles: ['R017001', 'AR000589'] }
      },
      {
        path: '/system-manage/applyStoreCode',
        name: 'applyStoreCode',
        component: () => import('@/views/system-manage/applyStoreCode/list'),
        meta: { title: '店内码流水号查询', icon: 'table', affix: true, roles: ['R017001', 'AR000589'] }
      },
      {
        path: '/system-manage/notice',
        name: 'notice',
        component: () => import('@/views/system-manage//notice/list'),
        meta: { title: '系统公告', icon: 'table', affix: true, roles: ['R017001', 'AR000589'] }
      },
      {
        path: '/system-manage/writeGuide',
        name: 'writeGuide',
        component: () => import('@/views/system-manage//writeGuide/list'),
        meta: { title: '填写指引管理', icon: 'table', affix: true, roles: ['R017001', 'AR000589'] }
      },
      {
        path: '/system-manage/pushresult',
        name: 'pushresult',
        component: () => import('@/views/system-manage/pushresult/index.vue'),
        meta: { title: '推送结果', icon: 'table', affix: true, roles: ['R017001', 'AR000589'] }
      },
      {
        path: '/coi/configuration/rule-config/variable/list',
        name: 'rule-variable',
        component: () => import('@/views/coi/configuration/rule-config/variable/list'),
        meta: { title: '线上规则变量配置', icon: 'table', affix: true }
      }
    ]
  },
  {
    path: '/readOnly',
    component: Layout,
    redirect: 'readOnly',
    children: [
      {
        path: '/new-item/readOnly',
        name: 'new_item_read_only',
        component: () => import('@/views/new-item/readOnly/index'),
        meta: { title: '建品任务查询', icon: 'table', affix: true, roles: ['R017001', 'R017005', 'R017007', 'AR000589'] }
      }
    ]
  },
  {
    path: '/newItemList',
    component: Layout,
    redirect: 'newItemList',
    children: [
      {
        path: '/system-manage/newItemList',
        name: 'newItemList',
        component: () => import('@/views/system-manage/newItemList/list'),
        meta: { title: '新品委员会清单', icon: 'table', affix: true, roles: ['R017001', 'R017006', 'R017002', 'R017003', 'AR000589'] }
      }
    ]
  },
  {
    path: '/report',
    component: Layout,
    redirect: 'report',
    meta: { title: '数据报表', icon: 'form', roles: ['R017001', 'AR000589'], affix: true },
    children: [
      {
        path: '/report/overviews',
        name: 'overviews',
        component: () => import('@/views/report/overviews'),
        meta: { title: '商品数据总览', icon: 'table', affix: true, roles: ['R017001', 'AR000589'] }
      }
    ]
  },
  {
    path: '/olm/phase',
    component: Layout,
    redirect: 'list',
    name: 'phase',
    meta: { title: 'O2O清单管理', icon: 'form', roles: ['R017001', 'R017008', 'R017007'], affix: true },
    children: [
      {
        path: '/olm/schedule/list',
        name: '/olm/phase',
        component: () => import('@/views/olm/schedule/list'),
        meta: { title: '档期管理', icon: 'table', roles: ['R017001', 'R017007'], affix: true }
      },
      {
        path: '/olm/itemlist',
        name: '/olm/item-list',
        component: () => import('@/views/olm/item-list/list'),
        meta: { title: '清单管理', icon: 'table', roles: ['R017001', 'R017008', 'R017007'], affix: true }
      },
      {
        path: '/olm/itemlist/audit',
        name: '/olm/item-list-audit',
        component: () => import('@/views/olm/audit-list/list'),
        meta: { title: '清单审核', icon: 'table', roles: ['R017001', 'R017007'], affix: true }
      },
      {
        path: '/olm/white-list/list',
        name: '/olm/whiteList',
        component: () => import('@/views/olm/white-list/list'),
        meta: { title: '商品白名单', icon: 'table', roles: ['R017001', 'R017008', 'R017007'], affix: true }
      },
      {
        path: '/olm/nbo-list/list',
        name: '/olm/nboList',
        component: () => import('@/views/olm/nbo-list/list'),
        meta: { title: 'NBO清单', icon: 'table', roles: ['R017001', 'R017007'], affix: true }
      }
    ]
  },
  {
    path: '/coi/category',
    component: Layout,
    redirect: 'list',
    name: 'phase',
    meta: { title: '线上基础信息管理', icon: 'form', roles: ['R017001', 'R017009', 'R017008', 'R017007', 'R017012', 'R017017', 'R017018'], affix: true },
    children: [
      {
        path: '/coi/category/store-list',
        name: 'store-list',
        component: () => import('@/views/coi/category/index'),
        meta: { title: '店内类目', icon: 'table', roles: ['R017001', 'R017012', 'R017007', 'R017008', 'R017017', 'R017018', 'R017009'], affix: true },
        children: [
          {
            path: '/coi/category/store-list/12',
            name: '/coi/category/store/12',
            component: () => import('@/views/coi/category/store-list'),
            meta: { title: '沃尔玛到家', icon: 'table', roles: ['R017001', 'R017012', 'R017007', 'R017008', 'R017017', 'R017018', 'R017009'], affix: true }
          },
          {
            path: '/coi/category/store-list/07',
            name: '/coi/category/store/07',
            component: () => import('@/views/coi/category/store-list'),
            meta: { title: '京东到家', icon: 'table', roles: ['R017001', 'R017012', 'R017007', 'R017008', 'R017017', 'R017018', 'R017009'], affix: true }
          },
          {
            path: '/coi/category/store-list/06',
            name: '/coi/category/store/06',
            component: () => import('@/views/coi/category/store-list'),
            meta: { title: '京东沃选', icon: 'table', roles: ['R017001', 'R017012', 'R017007', 'R017008', 'R017017', 'R017018', 'R017009'], affix: true }
          }
        ]
      },
      {
        path: '/coi/category/channel-list',
        name: '/coi/category/channel',
        component: () => import('@/views/coi/category/channel-list'),
        meta: { title: '渠道类目', icon: 'table', affix: true }
      },
      {
        path: '/coi/brand/brand-list',
        name: '/coi/brand/channel',
        component: () => import('@/views/coi/brand/brand-list'),
        meta: { title: '渠道品牌', icon: 'table', affix: true }
      }
    ]
  },
  {
    path: '/coi/mapping',
    component: Layout,
    redirect: 'list',
    name: 'phase',
    meta: { title: '线上映射管理', icon: 'form', roles: ['R017001', 'R017008', 'R017007'], affix: true },
    children: [
      {
        path: '/coi/mapping/brand',
        name: '/coi/mapping/brand',
        component: () => import('@/views/coi/mapping/brand-list'),
        meta: { title: '品牌映射', icon: 'table', roles: ['R017001', 'R017008', 'R017007'], affix: true }
      },
      {
        path: '/coi/mapping/fineline-category',
        name: '/coi/mapping/fineline-category',
        component: () => import('@/views/coi/mapping/fineline-category-list'),
        meta: { title: 'Fineline-类目映射', icon: 'table', roles: ['R017001', 'R017008', 'R017007'], affix: true }
      }
    ]
  },
  {
    path: '/',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/approvalDetails/:id/:mainStatus/:from/:tab',
        name: 'ApprovalDetails',
        hidden: true,
        component: () => import('@/views/coi/approve/index/approvalDetails'),
        meta: {
          title: '商品审核',
          icon: 'table',
          affix: true,
          custom: true,
          roles: ['R017001', 'R017002', 'R017008', 'R017007', 'R017010', 'R017012', 'AR000589']
        }
      },
      {
        path: '/addspu/:name/:modify',
        name: 'AddspuWMDj',
        hidden: true,
        component: () => import('@/views/coi/spuChannelInventory/components/addWmdj'),
        meta: {
          title: 'WMDJ系列品编辑',
          icon: 'table',
          affix: true,
          custom: true
        }
      }
      // {
      //   path: '/commodityM/approve-detail/:id/:mainStatus',
      //   name: 'ApproveDeta',
      //   hidden: true,
      //   component: () => import('@/views/coi/approve/components/approveDetail.vue'),
      //   meta: { title: '线上商品审核', icon: 'table', affix: true, custom: true, roles: ['R017001', 'R017002', 'R017007', 'R017008', 'R017010', 'R017012'] }
      // }
    ]
  },
  {
    path: '/coi',
    component: Layout,
    redirect: 'list',
    name: 'coi-online-build',
    meta: { title: '线上建品管理', icon: 'form', roles: ['R017001', 'R017002', 'R017007', 'R017012', 'R017008', 'R017010', 'R017019'], affix: true },
    children: [
      // {
      //   path: '/o2o/list',
      //   name: 'o2oViews',
      //   component: () => import('@/views/coi/reason/o2o/list'),
      //   meta: { title: '线上建品决策', icon: 'table', affix: true, roles: ['R017001', 'R017008', 'R017007'] }
      // },
      {
        path: '/purchaseApproval',
        name: 'PurchaseApprovalList',
        component: () => import('@/views/coi/approve/index/purchaseApprovalList'),
        meta: { title: '品类运营初审', icon: 'table', affix: true, roles: ['R017001', 'R017008', 'R017007'] }
      },
      {
        path: '/complianceApproval',
        name: 'ComplianceApprovalList',
        component: () => import('@/views/coi/approve/index/complianceApprovalList'),
        meta: { title: 'GBS 终审', icon: 'table', affix: true, roles: ['R017001', 'R017007', 'R017010'] }
      },
      //  roles: ['R017012']
      {
        path: '/errorFlag',
        name: 'ErrorFlag',
        component: () => import('@/views/coi/errorflag/index'),
        meta: { title: '文描错误标记', icon: 'table', affix: true, roles: ['R017001', 'R017012'] }
      },
      {
        path: '/onlineBuildingTasks',
        name: 'OnlineBuildingTasks',
        component: () => import('@/views/coi/schedule/index/onlineBuildingTasks.vue'),
        meta: { title: '线上建品任务', icon: 'table', affix: true, roles: ['R017001', 'R017002', 'R017007', 'R017008', 'R017012'] }
      },
      {
        path: '/CBEC/onlineBuildingTasks',
        name: 'CBECOnlineBuildingTasksCBEC',
        hidden: window.hidden_CBEC_iteration,
        component: () => import('@/views/coi/CBEC/index/index.vue'),
        meta: { title: 'CBEC线上建品', icon: 'table', affix: true, roles: ['R017001', 'R017019'] }
      },
      {
        path: '/CBEC/add/:upc/:type/:fromPage/:fromTab',
        name: 'CBEC_Add',
        hidden: true,
        component: () => import('@/views/coi/CBEC/index/add.vue'),
        meta: { title: 'CBEC商品新增', icon: 'table', affix: true, roles: ['R017001', 'R017019'], custom: true }
      },
      {
        path: '/CBEC/edit/:upc/:type/:fromPage/:fromTab',
        name: 'CBEC_Edit',
        hidden: true,
        component: () => import('@/views/coi/CBEC/index/edit.vue'),
        meta: { title: 'CBEC商品编辑', icon: 'table', affix: true, roles: ['R017001', 'R017019'], custom: true }
      },
      {
        // 详情制作页面
        path: '/VendorUpDataCreationOnlineInfo_Vendor',
        name: 'creationOnlineInfo',
        component: () => import('@/views/coi/making/making.vue'),
        meta: { title: '线上建品制作页', icon: 'table', affix: true, roles: ['R017001', 'R017002', 'R017007', 'R017012'] },
        hidden: true
      },
      {
        //  线上建品—补充委托信息
        path: '/VendoraddInformation_Vendor',
        name: 'addInformation',
        component: () => import('@/views/coi/making/addInformation.vue'),
        meta: { title: '补充渠道类目', icon: 'table', affix: true, roles: ['R017001', 'R017002', 'R017007', 'R017012'] },
        hidden: true
      },
      {
        path: '/scheduleList/newItemList',
        name: 'OnlineNewItemList',
        hidden: true,
        component: () => import('@/views/coi/schedule/index/newItemList.vue'),
        meta: { title: '新增建品', icon: 'table', affix: true, custom: true, roles: ['R017001', 'R017002', 'R017007', 'R017012'] }
      },
      {
        path: '/scheduleList/entrustInformation/:type/:idList',
        name: 'EntrustInformation',
        hidden: true,
        component: () => import('@/views/coi/schedule/index/entrustInformation.vue'),
        meta: { title: '补充委托信息', icon: 'table', affix: true, roles: ['R017001', 'R017002', 'R017007', 'R017012'] }
      },
      // {
      //   path: '/approvalDetails/:id/:mainStatus/:from/:tab',
      //   name: 'ApprovalDetails',
      //   hidden: true,
      //   component: () => import('@/views/coi/approve/index/approvalDetails'),
      //   meta: {
      //     title: '商品审核',
      //     icon: 'table',
      //     affix: true,
      //     custom: true,
      //     roles: ['R017001', 'R017002', 'R017008', 'R017007', 'R017010', 'R017012', 'AR000589']
      //   }
      // },
      {
        path: '/spuTeamDescription',
        name: 'SpuTeamDescription',
        hidden: window.appConfig.hiddenNewProducts || window.appConfig.hiddenNewProducts_Spu,
        component: () => import('@/views/coi/spuManagement/index/spuTeamDescription.vue'),
        meta: { title: 'SPU文描管理', icon: 'table', affix: true, roles: ['R017001', 'R017012'] }
      },
      {
        path: '/spuSeries/:spuId/:mainStatus/:from',
        name: 'SpuSeries',
        hidden: true,
        component: () => import('@/views/coi/spuManagement/index/spuSeries.vue'),
        meta: { title: 'SPU信息', icon: 'table', affix: true, custom: true, roles: ['R017001', 'R017002', 'R017007', 'R017012'] }
      },
      {
        path: '/spuSeriesMaintain/:spuId/:mainStatus/:from',
        name: 'SpuSeriesMaintain',
        hidden: true,
        component: () => import('@/views/coi/spuManagement/index/spuSeriesMaintain.vue'),
        meta: { title: 'SPU信息', icon: 'table', affix: true, custom: true, roles: ['R017001', 'R017002', 'R017007', 'R017012'] }
      },
      {
        path: '/commodityM/GoodsLibrary',
        name: 'GoodsLibrary',
        hidden: window.appConfig.hiddenNewProducts,
        component: () => import('@/views/coi/commodityM/goodsLibrary.vue'),
        meta: { title: '商品库', icon: 'table', affix: true, roles: ['R017001', 'R017002', 'R017007', 'R017008', 'R017012'] }
      },
      {
        path: '/commodityM/commodityEdit/:upc/:type/:from/:channelId',
        name: 'CommodityEdit',
        hidden: true,
        component: () => import('@/views/coi/commodityM/components/edit.vue'),
        meta: { title: '全渠道商品编辑', icon: 'form', affix: true, roles: ['R017001', 'R017002', 'R017007', 'R017008', 'R017012'], custom: true }
      },
      {
        path: '/channelInventory',
        name: 'ChannelInventory',
        component: () => import('@/views/coi/channelInventory/index.vue'),
        meta: { title: '渠道商品库', icon: 'table', affix: true, roles: ['R017001', 'R017002', 'R017007', 'R017008', 'R017012', 'R017019'] }
      },
      {
        path: '/commodityM/approve-detail/:id/:mainStatus/:from/:tab/:channelId',
        name: 'ApproveDetail2',
        hidden: true,
        component: () => import('@/views/coi/commodityM/approve-detail.vue'),
        meta: { title: '线上商品审核', icon: 'table', affix: true, custom: true, roles: ['R017001', 'R017002', 'R017007', 'R017008', 'R017010', 'R017012'] }
      },
      {
        path: '/coi/configuration/rule-config',
        name: 'rule-config',
        component: () => import('@/views/coi/configuration/index'),
        meta: { title: '线上建品配置', icon: 'table', affix: true, roles: ['R017001', 'R017007', 'R017012'] },
        children: [
          {
            path: '/coi/configuration/rule-config/variable/list',
            name: 'rule-variable',
            component: () => import('@/views/coi/configuration/rule-config/variable/list'),
            meta: { title: '规则变量配置', icon: 'form', affix: true },
            hidden: true
          },
          {
            path: '/coi/configuration/rule-config/rule/rule-list',
            name: 'rule',
            component: () => import('@/views/coi/configuration/rule-config/rule/list'),
            meta: { title: '建品规则设置', icon: 'form', affix: true }
          },
          {
            path: '/coi/configuration/context-vendor',
            name: '/coi/configuration/context-vendor',
            component: () => import('@/views/coi/configuration/context-vendor/list'),
            meta: { title: '文描供应商管理', icon: 'table', affix: true }
          },
          {
            path: '/coi/configuration/pb-mapping',
            name: '/coi/configuration/pb-mapping',
            component: () => import('@/views/coi/configuration/pb-mapping/list'),
            meta: { title: 'PB文描商设置', icon: 'table', affix: true }
          },
          {
            path: '/reason/list',
            name: 'reasonViews',
            component: () => import('@/views/coi/reason/list'),
            meta: { title: '驳回原因维护', icon: 'table', affix: true, roles: ['R017001', 'R017007', 'R017012'] }
          },
          {
            path: '/coi/configuration/whitelist-vendor-config',
            name: 'whitelistVendorConfig',
            component: () => import('@/views/coi/configuration/whitelist-vendor-config/index.vue'),
            meta: { title: '白名单供应商配置', icon: 'table', affix: true, roles: ['R017001', 'R017007', 'R017012'] }
          }
        ]
      }
    ]
  },
  {
    path: '/JDSupermarket',
    component: Layout,
    redirect: { name: 'JDSupermarketProducts' },
    name: 'JDSupermarket',
    meta: { title: '京超商品管理', icon: 'form', roles: ['R017001', 'R017002'], affix: true },
    children: [
      {
        path: 'list',
        name: 'JDSupermarketProducts',
        component: () => import('@/views/JDSupermarket/index/list.vue'),
        meta: { title: '京超商品管理', icon: 'table', affix: true }
      },
      {
        path: 'offer',
        name: 'JDSupermarketProductOffer',
        hidden: true,
        component: () => import('@/views/JDSupermarket/index/offer.vue'),
        meta: { title: '新增/更新报价', icon: 'table', roles: ['R017002'], affix: true }
      },
      {
        path: 'details/:id',
        name: 'JDSupermarketProductDetails',
        hidden: true,
        component: () => import('@/views/JDSupermarket/index/productDetails.vue'),
        meta: { title: '商品报价详情', custom: true, icon: 'table', affix: true }
      }
    ]
  },
  {
    path: '/commodityRestriction',
    component: Layout,
    redirect: '/commodityRestriction/hyper',
    meta: {
      title: '商品限购',
      icon: 'form',
      roles: ['R017001', 'AR000491', 'AR000493', 'AR000495', 'AR000497', 'AR000499', 'AR000428', 'AR000501'],
      affix: true
    },
    children: [
      {
        name: 'commodityRestrictionHyper',
        component: () => import('@/views/iframe/index.vue'),
        path: 'hyper',
        meta: {
          title: '限购商品列表',
          icon: 'list',
          roles: ['R017001', 'AR000491', 'AR000493', 'AR000495', 'AR000497', 'AR000499', 'AR000428', 'AR000501'],
          affix: true,
          baseUrl: window.restrictedPurchase,
          params: ['token', 'appName', 'APPID', 'userId', 'userName']
        }
      }
    ]
  },
  {
    path: '/freshOne',
    component: Layout,
    redirect: { name: 'CommodityInquiryRouter' },
    name: 'FreshOne',
    meta: { title: 'Fresh One', icon: 'form', roles: ['R017001', 'R017002', 'R017008'], affix: true },
    children: [
      {
        path: '/CommodityInquiryRouter',
        name: 'CommodityInquiryRouter',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '商品查询', icon: 'table', affix: true, baseUrl: window.freshOne, params: ['token', 'userName'] }
      },
      {
        path: '/PriceChangeShelfRouter',
        name: 'PriceChangeShelfRouter',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '变价开单上下架', icon: 'table', affix: true, baseUrl: window.freshOne, params: ['token', 'userName'] }
      },
      {
        path: '/BillingShelfApprovalRouter',
        name: 'BillingShelfApprovalRouter',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '开单上下架审批', icon: 'table', affix: true, baseUrl: window.freshOne, params: ['token', 'userName'] }
      },
      {
        path: '/ShelfExceptionReviewRouter',
        name: 'ShelfExceptionReviewRouter',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '例外预警', icon: 'table', affix: true, baseUrl: window.freshOne, params: ['token', 'userName'] }
      },
      {
        path: '/FrozenStoreInfoRouter',
        name: 'FrozenStoreInfoRouter',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '门店信息', icon: 'table', affix: true, baseUrl: window.freshOne, params: ['token', 'userName'] }
      },
      {
        path: '/PoShelfWhiteListRouter',
        name: 'PoShelfWhiteListRouter',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '上架白名单', icon: 'table', affix: true, baseUrl: window.freshOne, params: ['token', 'userName'] }
      }
      // {
      //   path: '/PoShelfWhiteListDetailRouter',
      //   name: 'PoShelfWhiteListDetailRouter',
      //   component: () => import('@/views/freshOne/index.vue'),
      //   meta: { title: '上架白名单内容', icon: 'table', affix: true }
      // }
      // {
      //   path: '/ShelfProductDetailsRouter',
      //   name: 'ShelfProductDetailsRouter',
      //   component: () => import('@/views/freshOne/index.vue'),
      //   meta: { title: '变价开单上下架内容', icon: 'table', affix: true }
      // },
      // {
      //   path: '/ApprovalDetailsRouter',
      //   name: 'ApprovalDetailsRouter',
      //   component: () => import('@/views/freshOne/index.vue'),
      //   meta: { title: '审批内容', icon: 'table', affix: true }
      // }
    ]
  },
  {
    path: '/itemcore-front',
    component: Layout,
    redirect: {
      name: 'itemCoreFrontUpcList'
    },
    meta: {
      title: '商品上下架管理',
      icon: 'form',
      roles: ['R017001', 'R017002', 'R017007', 'R017008'],
      affix: true
    },
    hidden: window.lowerShelfHidden,
    children: [
      {
        path: '/upcList',
        name: 'itemCoreFrontUpcList',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '商品列表', icon: 'table', affix: true, baseUrl: window.baseUrls, params: ['token', 'userName', 'userId'] }
      },
      {
        path: '/storeUpcList',
        name: 'itemCoreFrontStoreUpcList',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '门店商品列表', icon: 'table', affix: true, baseUrl: window.baseUrls, params: ['token', 'userName', 'userId'] }
      },
      {
        path: '/itemTask',
        name: 'itemCoreFrontItemTask',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '任务管理', icon: 'table', affix: true, baseUrl: window.baseUrls, params: ['token', 'userName', 'userId'] }
      },
      {
        path: '/itemWhiteList',
        name: 'itemCoreFrontItemWhiteList',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '商品白名单', icon: 'table', affix: true, baseUrl: window.baseUrls, params: ['token', 'userName', 'userId'] }
      },
      {
        path: '/channelsTakeeffect',
        name: 'itemCoreFrontChannelsTakeeffect',
        component: () => import('@/views/iframe/index.vue'),
        meta: { title: '渠道门店清单', icon: 'table', affix: true, baseUrl: window.baseUrls, params: ['token', 'userName', 'userId'] }
      }
      // {
      //   path: 'shelvesofGoodsFromstore',
      //   name: 'shelvesofGoodsFromstore',
      //   // component: () => import('@/views/coi/upper/detailed-list'),
      //   // meta: { title: '渠道门店清单', icon: 'table', affix: true }
      //   component: () => import('@/views/iframe/index.vue'),
      //   meta: { title: 'wms操作下架⻚⾯', icon: 'table', affix: true, baseUrl: window.baseUrls, params: ['token', 'userName', 'userId'] }
      // }
    ]
  }
]

const asyncRoutes = [{ path: '*', redirect: '/404', hidden: true }]

const createRouter = () => {
  return new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })
}

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}
router.selfaddRoutes = function (params) {
  router.matcher = new Router().matcher
  router.addRoutes(params)
}

export default router
export { asyncRoutes }
